from django.shortcuts import render
from django.http import HttpResponse, HttpResponseRedirect
from django.urls import reverse_lazy, reverse
from django.views.generic import CreateView
from .forms import RegisterForm

# the index either redirects to login page or the zylinder game
def index(request):
    if request.user.is_authenticated:
        return HttpResponseRedirect(reverse('zylinder_app:main'))
    else:
        return HttpResponseRedirect(reverse('login'))

class RegisterView(CreateView):
    form_class = RegisterForm
    success_url = reverse_lazy('login')
    template_name = 'registration/register.html'
